package cn.wellwan.observer.utilobserver;

import cn.wellwan.observer.Observer;

import java.util.ArrayList;
import java.util.Observable;

/**
 * creator: maokai
 * on: 2018/3/27
 * description: 气象站
 */
public class WeatherData extends Observable {

    private float temperature;
    private float humidity;
    private float pressure;

    public WeatherData () {

    }

    /**
     * 气象站得到数据
     * @param temperature
     * @param humidity
     * @param pressure
     */
    public void setMeasurements (float temperature , float humidity , float pressure) {
        this.temperature = temperature;
        this.humidity = humidity;
        this.pressure = pressure;
        this.measurementsChanged();
    }

    /**
     * 当气象站得到更新观测值时通知观察者
     */
    public void measurementsChanged() {
        this.setChanged();
        this.notifyObservers();
    }
    //观察者拉去数据的方法
    public float getTemperature () {
        return temperature;
    }

    public float getHumidity () {
        return humidity;
    }

    public float getPressure () {
        return pressure;
    }
}
